package com.jinyi.wwdeng.ui.user.adapter

import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.jinyi.base.utils.img.ImageUtil
import com.jinyi.lib_baseadapter.BGARecyclerViewAdapter
import com.jinyi.lib_baseadapter.BGAViewHolderHelper
import com.jinyi.wwdeng.R
import org.json.JSONObject

/**
 * JinYiTest
 * @Author wwdeng
 * @CreateTime: 2024/4/19 12:02
 * @Annotation：意见反馈 - 联系方式列表
 */
class UserFeedbackImageAdapter(recyclerView: RecyclerView?): BGARecyclerViewAdapter<JSONObject>(recyclerView,R.layout.item_feedback_image) {

    override fun setItemChildListener(helper: BGAViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.ivDelete) //删除
        helper.setItemChildClickListener(R.id.ivImage)//选择
    }

    override fun fillData(helper: BGAViewHolderHelper, position: Int, model: JSONObject) {
        val ivImage = helper.getImageView(R.id.ivImage)
        val ivDelete = helper.getImageView(R.id.ivDelete)

        //是否是默认图片
        val isDefault = model.optBoolean("isDefault",true)
        if (isDefault){
            ivImage.setImageResource(R.mipmap.pic_user_feedback_upload_icon)
            ivDelete.visibility = View.INVISIBLE
        } else {
            ImageUtil.getInstance().loadImage(mContext,ivImage,model.optString("imgPath"))
            ivDelete.visibility = View.VISIBLE
        }
    }
}